Add typed RateLimitException and ForbiddenException - #8
Merged
Conversation
429 responses now throw RateLimitException carrying the Retry-After delay in seconds, and 403 responses throw ForbiddenException with the API message, so the CLI can retry rate limits with backoff and explain ability rejections (the public CI token hitting a non-analyze endpoint) instead of collapsing both into the generic ApiException. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Apply the review findings from codex and claude: parse the HTTP-date form of Retry-After, clamp negative and round up fractional delays so callers can sleep the value as-is, prefer the API's message over the hardcoded fallback, and lock the new exceptions' ApiException catchability in tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
GlimpseImg\ becomes MathiasGrimm\GlimpsePhp\, aligning the SDK with the MathiasGrimm vendor namespace used across the other packages. Breaking change: consumers must update their imports. The Composer package name stays mathiasgrimm/glimpse-php. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…limpsephp Rename the namespace to MathiasGrimm\GlimpsePhp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RateLimitException(extendsApiException) is thrown on 429 responses. It carriesretryAfterSeconds, parsed from theRetry-Afterheader in both RFC 9110 forms (delay-seconds and HTTP date), clamped to never be negative and rounded up, so a caller cansleep()the value as-is. Missing or unparseable headers yieldnull.ForbiddenException(extendsApiException) is thrown on 403 responses with the API's message.ApiException, locked by a test, so existing consumers keep working.Why
The glimpse CLI is gaining a built-in public analyze-only token so
glimpse checkworks on fork pull requests (see glimpseimg.com PR #77). The CLI needs to retry rate limits with backoff and explain ability rejections; the genericApiExceptioncould not carry either signal.Release
Tag as v2.1.0 after merge. The glimpse-cli PR depends on this release.
Reviewed by codex and claude CLIs; their findings (HTTP-date parsing, clamping, message preservation, catchability test) are included.
🤖 Generated with Claude Code